package com.xuecheng.order.job;

import cn.hutool.core.date.DateUtil;
import com.xuecheng.order.service.OrdersService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


// 清理超时订单定时任务类
@Component
@Slf4j
public class OrdersJob {


    @Autowired
    private OrdersService ordersService;

    @Scheduled(cron = "0/30 * * * * ?")
    public void clearOrders(){
        log.info("清理超时订单：{}", DateUtil.now());
        ordersService.clearOrders();
    }
}
